package com.jt.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author 张琪
 * @date 2020/11/30
 * @describe
 */

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
//        this.strictInsertFill(metaObject, "created", Date.class, new Date());
        Date date = new Date();
        this.fillStrategy(metaObject, "created", date);
        this.fillStrategy(metaObject, "updated", date);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        this.strictUpdateFill(metaObject, "updated", Date.class, new Date());
        fillStrategy(metaObject, "updated", new Date());
    }
}
